package penguin.masking.jdbc;

import penguin.masking.Logger;

import java.sql.Connection;
import java.sql.ResultSet;

/**
 * @author wuxh
 * @version 1.0.0
 */
public class OracleMetaHandler extends AbstractDBMetaHandler {

    @Override
    public String userName(ResultSet set) {
        try {
            final Connection connection = set.getStatement().getConnection();
            String user = doCheck(new LoopCallCheck<String>() {
                @Override
                public String hashValue() {
                    return "userName-" + connection.toString();
                }

                @Override
                public String call() throws Exception {
                    return connection.getMetaData().getUserName();
                }
            });
            return user;
        } catch (Exception e) {
            e.printStackTrace();
            Logger.error("用户获取异常!", e);
        }
        return null;
    }
}

